# -*- Makefile -*-
RM = rm -f
MKDIR = mkdir -p

DEVKIT2 = $(CAANOODEV)/include
DEVKIT = $(CAANOODEV)/tools/gcc-4.2.4-glibc-2.7-eabi
CXX = $(DEVKIT)/bin/arm-gph-linux-gnueabi-g++
CC = $(DEVKIT)/bin/arm-gph-linux-gnueabi-g++
STRIP = $(DEVKIT)/bin/arm-gph-linux-gnueabi-sstrip


CXXFLAGS =   -I"$(DEVKIT2)" -I"include" -D_CAANOO_ -msoft-float -Os
LDFLAGS = -L"$(CAANOODEV)/lib" -lpthread -ljpeg -lpng -lSDL -lSDL_image -lutil -lz
STRIPFLAGS = -R .comment -R .note -R .note.ABI-tag

OBJS  = obj/termula2x.o obj/pty.o obj/stermbutton.o obj/font.o obj/stermsection.o obj/stermkeyboard.o obj/stermkey.o obj/touchscreen.o

TARGET = bin/termula2x-caanoo-dynamic

obj/%.o: src/%.cpp
		$(CXX) $(CXXFLAGS) -o $@ -c $<

obj/%.o: src/%.c
		$(CC) $(CXXFLAGS) -o $@ -c $<

all: dir $(TARGET)

dir:
	@if [ ! -d obj ]; then $(MKDIR) obj; fi

$(TARGET): $(OBJS)
		@echo "*** Linking $(TARGET)..."
		$(CXX) -o $(TARGET) $(OBJS) $(LDFLAGS)
		$(STRIP) $(TARGET) #Don't strip if symbols are needed for gprof

clean:
		$(RM) obj/*.o $(TARGET)
